import defaultImg from '@/components/defaultImg/defaultImg'//默认图
export default {
  components: {
    defaultImg
  },
  data() {
    return {
      pageLoading: false,
      type: '',
      addList: '',
      pagesIndex: 1,
      loadStatus: '',
    }
  },
  onLoad(option) {
    this.type = option.type
  },
  onShow(){
    // debugger
    this.addList = []
    this.pagesIndex = 1
    this.getList()
  },
  created() {

  },
  methods: {
    onReachBottom(){
		  this.getList()
    },
    more(){
      this.getList()
    },
    // 加载前、中、后
    moreStatus(status) {
		  this.loadStatus = status
    },
    async getList() {
      uni.showLoading({
			    title: '加载中'
      })
      this.loadStatus = 'loading'
      try {
        let data = {
          'PageIndex': this.pagesIndex,
          'PageSize': 10,
          'app_type': 1
        }
        const res = await this.$api.common.addressList(data)

        this.addList = [...this.addList, ...res.data.list]
        this.$nextTick(() => {
          this.pageLoading = true
        })
        if(res.data.total <= 10){
				  this.loadStatus = 'nomore'
        }else{
				  this.moreStatus(res.data.list.length !== 0 ? 'loadmore' : 'nomore')
        }
        uni.hideLoading()
        if (res.data.list.length === 0) return false
        this.pagesIndex += 1 // 当前页加1
      } catch (e) {
        console.log(e)
      }
    },
    clickOther(item) {
      console.log(item)
      if (this.type === 110) {
        uni.$emit('Newinquiry', {
          area: item.district, //区
          city: item.city,
          province: item.province, //省
          address: item.address,
          name: item.name,
          mobile: item.mobile
        })
      }
    },
    goEdit(id) {
      let list = JSON.stringify(id)
      console.log(id,'值')
      uni.navigateTo({
        url: '/pages_userModule/my_eqit_address/my_eqit_address?list='+list
      })
    },
    //添加新地址跳转链接
    addnewaddress() {
      uni.navigateTo({
        url: '/pages_userModule/my_add_address/my_add_address'
      })
    }
  }
}
